package 面试.遍历算法.String类型题目;

public class 去重 {
    public static void main(String[] args) {
        String str="a,b,g,s,f,d,s,d,b";
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < str.length(); i++) {
            if((str.charAt(i) + "").matches("[a-zA-Z]")){
                String str1 = str.charAt(i) + "";
                if(str.indexOf(str1) == str.lastIndexOf(str1)){
                    stringBuilder.append(str1 + " ");
                }else {
                    if(str.indexOf(str1) == i){
                            stringBuilder.append(str1 + " ");
                    }
                }
            };
        }
        System.out.println(stringBuilder);
    }


}
